package com.mls.fivedistrict.controller.portal;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mls.fivedistrict.common.PageFilter;
import com.mls.fivedistrict.common.RequestHolder;
import com.mls.fivedistrict.common.ServiceResponse;
import com.mls.fivedistrict.pojo.HotWord;
import com.mls.fivedistrict.server.HotWordService;
import com.mls.fivedistrict.util.validator.BeanValidator;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController("backendHotWordController")
@RequestMapping("/api/app")
public class HotWordController {
    @Autowired
    HotWordService hotWordService;

    @GetMapping("/v1/hotWords")
    public ServiceResponse getList() {
        PageFilter pageFilter = RequestHolder.getPageFilter();
        PageHelper.startPage(pageFilter.getPageNum(), pageFilter.getPageSize());
        List<HotWord> hotWordList = hotWordService.selectList(pageFilter.getWrapper());
        PageInfo pageInfo = new PageInfo<HotWord>(hotWordList, 5);
        return ServiceResponse.createSuccessResponse(pageInfo);
    }
}
